using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using AmazonCommon.Amazon.ECS;
using Google.GData.YouTube;
using DDNY.WebPortals.Common;

namespace AmazonVer3.Controllers
{
    public class VideoController : ApplicationController
    {
        //
        // GET: /Video/

        public ActionResult List(string id, string page)
        {
            Item product = AmazonHelper.GetProductDetail(id);

            List<YouTubeEntry> movies = YoutubeHelper.FindVideoEntriesByKeyWord(product.ItemAttributes.Title);
            ViewData[VDConstants.CurrentASIN] = id;
            ViewData[VDConstants.PageTitle] = "Video Results For " + product.ItemAttributes.Title;
            ViewData[VDConstants.ProductToShow] = product;
            return View(movies);
        }

        public ActionResult Show(string id, string page)
        {
            Item product = AmazonHelper.GetProductDetail(id);

            YouTubeEntry video = YoutubeHelper.GetVideoById(page);
            ViewData[VDConstants.CurrentASIN] = id;            
            if (video != null)
            {                
                ViewData[VDConstants.PageTitle] = video.Title.Text;
                //ViewData[VDConstants.ShouldIndex] = "NOINDEX";
                ViewData[VDConstants.ProductToShow] = product;
                return View(video);
            }
            else
            {
                return new PermanentRedirectResult("~/Product/ShowProductDetails/" + id);
            }



        }

    }
}
